import { defineStore } from 'pinia';

// 菜单类型
interface MenuState {
  menus?: any[];
  selectedMenu?: any;
  selectedMenus?: string[];
}

export const useMenuStore = defineStore('user', {
  state: (): MenuState => ({
    menus: [],
    selectedMenu: null,
    selectedMenus: [],
  }),
  getters: {
    getMenus: (state) => state.menus,
    getSelectedMenu: (state) =>state.selectedMenu,
    getSelectedMenus: (state) => state.selectedMenus,
  },
  actions: {
    setMenus(menus) {
        this.menus = menus;
    },
    setSelectedMenu(selectedMenu) {
        this.selectedMenu = selectedMenu;
    },
    setSelectedMenus(selectedMenus) {
        this.selectedMenus = selectedMenus;
    }
  },
  // 启用持久化
  persist: true
})